package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DataTag;
import com.ruoyi.system.service.IDataTagService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 数据标签管理Controller
 * 
 * @author ruoyi
 * @date 2025-03-22
 */
@RestController
@RequestMapping("/system/DataTag")
public class DataTagController extends BaseController
{
    @Autowired
    private IDataTagService dataTagService;

    /**
     * 查询数据标签管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:DataTag:list')")
    @GetMapping("/list")
    public TableDataInfo list(DataTag dataTag)
    {
        startPage();
        List<DataTag> list = dataTagService.selectDataTagList(dataTag);
        return getDataTable(list);
    }

    /**
     * 导出数据标签管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:DataTag:export')")
    @Log(title = "数据标签管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataTag dataTag)
    {
        List<DataTag> list = dataTagService.selectDataTagList(dataTag);
        ExcelUtil<DataTag> util = new ExcelUtil<DataTag>(DataTag.class);
        util.exportExcel(response, list, "数据标签管理数据");
    }

    /**
     * 获取数据标签管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:DataTag:query')")
    @GetMapping(value = "/{dataTagId}")
    public AjaxResult getInfo(@PathVariable("dataTagId") Long dataTagId)
    {
        return success(dataTagService.selectDataTagByDataTagId(dataTagId));
    }

    /**
     * 新增数据标签管理
     */
    @PreAuthorize("@ss.hasPermi('system:DataTag:add')")
    @Log(title = "数据标签管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataTag dataTag)
    {
        return toAjax(dataTagService.insertDataTag(dataTag));
    }

    /**
     * 修改数据标签管理
     */
    @PreAuthorize("@ss.hasPermi('system:DataTag:edit')")
    @Log(title = "数据标签管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataTag dataTag)
    {
        return toAjax(dataTagService.updateDataTag(dataTag));
    }

    /**
     * 删除数据标签管理
     */
    @PreAuthorize("@ss.hasPermi('system:DataTag:remove')")
    @Log(title = "数据标签管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dataTagIds}")
    public AjaxResult remove(@PathVariable Long[] dataTagIds)
    {
        return toAjax(dataTagService.deleteDataTagByDataTagIds(dataTagIds));
    }
}
